           package com.java.diagnostics.visualizer.impl.selection;
           
           import java.util.ArrayList;
           import java.util.List;
           import org.eclipse.jface.viewers.ISelection;
           import org.eclipse.jface.viewers.ISelectionChangedListener;
           import org.eclipse.jface.viewers.ISelectionProvider;
           import org.eclipse.jface.viewers.SelectionChangedEvent;
           import org.eclipse.jface.viewers.StructuredSelection;
           
           public class GCAndMemoryVisualizerSelectionProvider
             implements ISelectionProvider
           {
             private ISelection selection;
             private List listeners = new ArrayList();
           
             public void addSelectionChangedListener(ISelectionChangedListener listener)
             {
               this.listeners.add(listener);
             }
           
             public ISelection getSelection()
             {
               if (this.selection == null)
               {
                 this.selection = StructuredSelection.EMPTY;
               }
               return this.selection;
             }
           
             public void removeSelectionChangedListener(ISelectionChangedListener listener) {
               this.listeners.remove(listener);
             }
           
             public void setSelection(ISelection selection)
             {
               this.selection = selection;
               SelectionChangedEvent e = new SelectionChangedEvent(this, selection);
               Object[] listenersArray = this.listeners.toArray();
           
               for (int i = 0; i < listenersArray.length; i++) {
                 ISelectionChangedListener l = (ISelectionChangedListener)listenersArray[i];
                 l.selectionChanged(e);
               }
             }
           }

